#include <mpi.h>
#include <stdio.h>
#include <unistd.h>

#define PRINTR(format,...) \
if (rank==0) printf(format,##__VA_ARGS__)

#define PRINTI(format,...) \
printf("Proc#%d:\t" format,rank,##__VA_ARGS__)


#define PRINTRD(format,...) \
MPI_Barrier(MPI_COMM_WORLD); PRINTR(format,##__VA_ARGS__)

#define PRINTID(format,...) \
MPI_Barrier(MPI_COMM_WORLD); PRINTI(format,##__VA_ARGS__)

int main(int argc, char** argv){
    int rank, nproc;
    int TAG = 100;
    MPI_Request send_request, recv_request;
    MPI_Status send_status, recv_status;
    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &nproc);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    printf("rank=%d\tnproc=%d\n",rank,nproc);
    MPI_Finalize();
}